#include "TabelMK.h"
#include "..\MesinKata\mesinkata.h"
#include "..\LinkedListGeneralDefinition\LinkedListGeneralDefinition.h"
#include "..\Owner\Owner.h"


int main() {
	TabelMK T = CreateEmptyTabelMK();
	PrintTabelMK(T); puts("-");
	AddRecordMK(AllocateRecordMK(CharToString("IF2030"), CharToString("Algoritma dan Struktur Data"), 4, CharToString("Pemrogaman")), &T);
	PrintTabelMK(T); puts("-");
	AddRecordMK(AllocateRecordMK(CharToString("EL2091"), CharToString("Sistem Digital"), 3, CharToString("Elektronika")), &T);
	AddRecordMK(AllocateRecordMK(CharToString("IF2132"), CharToString("Basis Data"), 3, CharToString("Basisdata")), &T);
	AddRecordMK(AllocateRecordMK(CharToString("KU1071"), CharToString("Pengantar Teknologi Informasi A"), 2, CharToString("Pemrogaman")), &T);
	PrintTabelMK(T); puts("-");
	
	bool querytrue = true;
	while(querytrue) {
		printf(">> Query : "); ReadArguments(NULL);
		AddressMK MK;
		TRAVERSETOEND2(MK,FIRST(T)) {
			if(!querytrue) break;
			if(EvaluateQueryTabelMK(MK,CReader,&querytrue)) { PrintRecordMK(MK,true,true,true,true); puts(""); }
		}
	}
	
	DestroyRecordMK(SearchRecordMKByKode(CharToString("EL2091"), &T), &T);
	if(SearchRecordMKByKode(CharToString("IF2030"), &T)!=NULL) puts("IF2030 ADA!"); else puts("IF2030 GA ADA!");
	PrintTabelMK(T); puts("-");
	printf("size first = %d", GetRecordMKSize(FIRST(T)));
	printf("\n");
	printf("Menghapus isi tabel T\n");
	DestroyTabelMK(&T);
	PrintTabelMK(T); puts("-");

	return 0;
}
